package com.titar.robot.db;


import com.titar.robot.RobotApp;
import com.titar.robot.entity.CacheTableData;

import androidx.annotation.NonNull;
import androidx.room.Database;
import androidx.room.DatabaseConfiguration;
import androidx.room.InvalidationTracker;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;

@Database(
        entities = {CacheTableData.class},
        version = 1)
public abstract class RobotDatabase extends RoomDatabase {

    private static volatile RobotDatabase INSTANCE;

    public static RobotDatabase getDatabase() {
        if (INSTANCE == null) {
            synchronized (RobotDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(RobotApp.getContext(),
                            RobotDatabase.class, "robot_database")
                            .allowMainThreadQueries().build();
                }
            }
        }
        return INSTANCE;
    }

    @NonNull
    @Override
    protected SupportSQLiteOpenHelper createOpenHelper(DatabaseConfiguration config) {
        return null;
    }

    @NonNull
    @Override
    protected InvalidationTracker createInvalidationTracker() {
        return null;
    }

    @Override
    public void clearAllTables() {

    }

    public abstract CacheTableDao cacheTableDao();
}
